package com.supersonic.backend.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.supersonic.backend.DAO.IUserDAO;
import com.supersonic.backend.model.User;
import com.supersonic.backend.service.IUserService;

@Service
@Transactional
public class UserService extends CommonService<User> implements IUserService {
	
	@Autowired
	private IUserDAO userDao;
	
	
	public User getUserByName(String name) {
		List<User> l = userDao.list();
		User u = null;
		if(l != null) {
			for(User user:l) {
				if(user.getName().equalsIgnoreCase(name)) {
					u = user;
					break;
				}
			}
			
		}
		return u;
	}
	

	public void addUser(User u) {
		userDao.addUser(u);
	}


	@Override
	public User getUserById(String id) {
		return userDao.findById(id);
	}


}
